package com.xqls.server.dto.send;

import com.xqls.server.dto.SoketCommonDto;
import com.xqls.server.netty.DecoderUtil;
import io.netty.buffer.ByteBuf;

/**
 * 采样仪采样设置
 */
public class SamplingSetDto extends SoketCommonDto {

    /**
     * 复位
     */
    public static  final  String MODEL_DEFAULT="0000";

    /**
     * 周期采样
     */
    public static  final  String MODEL_PERIODIC="0001";
    /**
     * 整点采样
     */
    public static  final  String MODEL_PUNCTUALITY="0002";
    /**
     * 流量累计采样
     */
    public static  final  String MODEL_ACCUMULATE="0003";

    /**
     * 瞬时流量触发采样模式
     */
    public static  final  String MODEL_INSTANTANEOUS="0004";

    /**
     * 液位触发采样模式
     */
    public static  final  String MODEL_LEVEL="0005";

    /**
     * 周期采样模式
     */
    private  String periodicMode;
    
    
    /**
     * 比例
     */
    private  Integer percent;
    /**
     *
     * 流量累积阈值（当采样模式设置为0x00，0x03）单位吨
     * 流量触发阈值（当采样模式设置为0x00，0x04）单位吨/小时
     * 采样模式设置为其他值，本4字节无效
     */

    private  Integer   threshold;
    /**
     * 水量
     */
    private Integer water;

    /**
     * 周期
     * 采样周期（当采样模式设置为0x00，0x01）单位分钟
     * 触发周期（当采样模式设置为0x00，0x04）单位分钟
     * 采样模式设置为其他值，本4字节无效
     */
    private Integer  cycle;

    /**
     * 大周期
     * 采样大周期，设定一个大循环采样的时间，单位h
     */
    private Integer bigCycle;

    /**
     * 延时启动小时数，设置0x08，0x08，0x08，0x08表示立即启动，设置<8888，表示延时设置的若干小时后再启动
     */
    private  Integer  delayedStar;


    public String getPeriodicMode() {
        return periodicMode;
    }

    public void setPeriodicMode(String periodicMode) {
        this.periodicMode = periodicMode;
    }

    public Integer getPercent() {
        return percent;
    }

    public void setPercent(Integer percent) {
        this.percent = percent;
    }

    public Integer getThreshold() {
        return threshold;
    }

    public void setThreshold(Integer threshold) {
        this.threshold = threshold;
    }

    public Integer getWater() {
        return water;
    }

    public void setWater(Integer water) {
        this.water = water;
    }

    public Integer getCycle() {
        return cycle;
    }

    public void setCycle(Integer cycle) {
        this.cycle = cycle;
    }

    public Integer getBigCycle() {
        return bigCycle;
    }

    public void setBigCycle(Integer bigCycle) {
        this.bigCycle = bigCycle;
    }

    public Integer getDelayedStar() {
        return delayedStar;
    }

    public void setDelayedStar(Integer delayedStar) {
        this.delayedStar = delayedStar;
    }

    public Integer getLength(){
        return 26;
    }
    public String getCode() {
        return "ca";
    }
    

   

	public void encode( ByteBuf byteBuf){
        byteBuf.writeBytes(DecoderUtil.hexStringToBytes(this.getPeriodicMode()));
        if(this.getPercent()!=null){
        DecoderUtil.integerToBytes(this.getPercent(),byteBuf,2);
        }else{
            DecoderUtil.integerToBytes(55,byteBuf,2);
        }
        if(this.getThreshold()!=null){
        DecoderUtil.integerToBytes(this.getThreshold(),byteBuf,4);
        }else{
            DecoderUtil.integerToBytes(33,byteBuf,4);
        }
        if(this.getWater()!=null){
        DecoderUtil.integerToBytes(this.getWater(),byteBuf,4);	
        }else{
            DecoderUtil.integerToBytes(400,byteBuf,4);
        }
        if(this.getCycle()!=null){
        DecoderUtil.integerToBytes(this.getCycle(),byteBuf,4);	
        }else{
            DecoderUtil.integerToBytes(60,byteBuf,4);
        }
        if(this.getBigCycle()!=null){
        DecoderUtil.integerToBytes(this.getBigCycle(),byteBuf,2);
        }else{
            DecoderUtil.integerToBytes(72,byteBuf,4);
        }
        if(this.getDelayedStar()!=null){
        DecoderUtil.integerToBytes(this.getDelayedStar(),byteBuf,4);
        }else{
            DecoderUtil.integerToBytes(3,byteBuf,4);
        }
        super.encode(byteBuf);
    }
}
